<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <canvas id="canvas" width="400" height="400"></canvas>
    <script>
        console.log('加载');
        
        const canvas = document.getElementById('canvas')
        const ctx = canvas.getContext('2d')
        ctx.fillStyle = 'red'
        ctx.fillRect(0, 0, 50, 50)
        ctx.beginPath()
        //线段
        ctx.lineWidth = 1
        ctx.strokeStyle = 'blue'
        ctx.lineJoin = "miter"
        ctx.moveTo(100, 100)
        ctx.lineTo(200, 200)
        ctx.lineTo(200, 100)
        ctx.lineTo(100,100)
        ctx.stroke()
        //圆形
        ctx.beginPath()
        ctx.lineWidth = 2
        ctx.strokeStyle = 'green'
        ctx.fillStyle = 'red'
        ctx.arc(300, 300, 50 , 0, 2*Math.PI) //arc绘制圆形
        ctx.stroke()
        ctx.fill()
        //点
         ctx.beginPath()
        //线段
        ctx.lineWidth = 1
        ctx.strokeStyle = 'red'
        ctx.moveTo(380, 50)
        ctx.lineTo(381, 51)
        ctx.closePath()
        ctx.stroke()
        ctx.font = "48px serif";
        ctx.direction = "rt1"
        ctx.strokeText("你好世界", 50, 50);

    </script>
</body>
</html>